package o;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

@RestrictTo({d.ॱ})
public final class fr {
    private final ColorStateList ˊ;
    private final Shader ˋ;
    private int ˎ;

    private fr(Shader shader, ColorStateList colorStateList, @ColorInt int i) {
        this.ˋ = shader;
        this.ˊ = colorStateList;
        this.ˎ = i;
    }

    static fr ˏ(@NonNull Shader shader) {
        return new fr(shader, null, 0);
    }

    static fr ˎ(@NonNull ColorStateList colorStateList) {
        return new fr(null, colorStateList, colorStateList.getDefaultColor());
    }

    static fr ˏ(@ColorInt int i) {
        return new fr(null, null, i);
    }

    @Nullable
    public Shader ˎ() {
        return this.ˋ;
    }

    @ColorInt
    public int ˋ() {
        return this.ˎ;
    }

    public void ˊ(@ColorInt int i) {
        this.ˎ = i;
    }

    public boolean ˏ() {
        return this.ˋ != null;
    }

    public boolean ˊ() {
        return this.ˋ == null && this.ˊ != null && this.ˊ.isStateful();
    }

    public boolean ˎ(int[] iArr) {
        if (!ˊ()) {
            return false;
        }
        int colorForState = this.ˊ.getColorForState(iArr, this.ˊ.getDefaultColor());
        if (colorForState == this.ˎ) {
            return false;
        }
        this.ˎ = colorForState;
        return true;
    }

    public boolean ॱ() {
        return ˏ() || this.ˎ != 0;
    }

    @Nullable
    public static fr ˎ(@NonNull Resources resources, @ColorRes int i, @Nullable Theme theme) {
        try {
            return ॱ(resources, i, theme);
        } catch (Throwable e) {
            Log.e("ComplexColorCompat", "Failed to inflate ComplexColor.", e);
            return null;
        }
    }

    @NonNull
    private static fr ॱ(@NonNull Resources resources, @ColorRes int i, @Nullable Theme theme) throws IOException, XmlPullParserException {
        int next;
        XmlPullParser xml = resources.getXml(i);
        AttributeSet asAttributeSet = Xml.asAttributeSet(xml);
        do {
            next = xml.next();
            if (next == 2) {
                break;
            }
        } while (next != 1);
        if (next != 2) {
            throw new XmlPullParserException("No start tag found");
        }
        String name = xml.getName();
        Object obj = -1;
        switch (name.hashCode()) {
            case 89650992:
                if (name.equals("gradient")) {
                    next = 1;
                    break;
                }
                break;
            case 1191572447:
                if (name.equals("selector")) {
                    obj = null;
                    break;
                }
                break;
        }
        switch (obj) {
            case null:
                return ˎ(fp.ˏ(resources, xml, asAttributeSet, theme));
            case 1:
                return ˏ(fq.ˋ(resources, xml, asAttributeSet, theme));
            default:
                throw new XmlPullParserException(xml.getPositionDescription() + ": unsupported complex color tag " + name);
        }
    }
}
